package com.example.blog.config;

import org.springframework.web.bind.annotation.ExceptionHandler;

import java.util.HashMap;

/**
 * @description: 统一异常拦截处理
 * @author: chengbaiyi
 * @create: 2022-08-17 17:21
 */
public class MyExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public Object exceptionAdvice(Exception e) {
        HashMap<String, Object> result = new HashMap<>();
        result.put("state", -1);
        result.put("msg", "程序出现异常：" + e.getMessage());
        result.put("data", "");
        return result;
    }
}
